home *** CD-ROM | disk | FTP | other *** search
/ Savor the Moment - Entert…ing Without Reservations / Savoe the Moment - Entertaining Without Reservations.iso / pc / Full_In / _SETUP.1 / Resources.dxr / 00002_Jump Back Button.ls < prev    next >
Encoding:
Text File  |  1999-10-03  |  4.5 KB  |  102 lines

  1. property myStateBehavior, myState
  2. global gNavigationButtonList
  3.  
  4. on getBehaviorDescription me
  5.   return "JUMP BACK BUTTON" & RETURN & RETURN & "Clicking on a sprite with this behavior will take the user back to previously visited markers in all movies." & RETURN & RETURN & "This behavior works in association with the 'Jump to Marker Button' and/or the Jump to Movie Button' behaviors.  It can also be used with the 'Jump Forward Button' behavior." & RETURN & RETURN & "These behaviors store visited markers in a global variable: gNavigationButtonList.  While authoring, the Jump Back Button may take you back to other (unconnected) movies where you used the same behavior.  If you find this disconcerting, type 'clearGlobals' into the Message Window before you run your current movie." & RETURN & RETURN & "If you wish to use the 'Jump...' behaviors both on the Stage and in a MIAW, and you wish to make the content of each entirely separate, you will need to create a copy of the whole set of behaviors, and change all occurrences of the global name in all the behaviors in one set.  (Use the Find command, followed by the 'Replace all' button, limiting the search to the current script).  Use one set of behaviors for the MIAW and the other for the Stage." & RETURN & RETURN & "PERMITTED MEMBER TYPES" & RETURN & "Graphic members" & RETURN & RETURN & "PARAMETERS: None" & RETURN & RETURN & "ASSOCIATED BEHAVIORS:" & RETURN & "+ Jump to Marker Button" & RETURN & "+ Jump to Movie Button" & RETURN & "+ Jump Forward Button" & RETURN & "+ Push Button (to alter rollover / mouseDown states)"
  6. end
  7.  
  8. on getBehaviorTooltip me
  9.   return "Use with graphic members." & RETURN & RETURN & "This behavior can only be used in conjunction with the" & RETURN & "'Jump to Marker Button' and/or 'Jump to Movie Button'" & RETURN & "behaviors.  When the user clicks on a sprite with this" & RETURN & "behavior the playback will return to the markers/movies" & RETURN & "previously visited using the 'Jump to... Button'" & RETURN & "behaviors."
  10. end
  11.  
  12. on beginSprite me
  13.   Initialize(me)
  14. end
  15.  
  16. on prepareFrame me
  17.   if myStateBehavior.count() then
  18.     CheckIfActive(me)
  19.   end if
  20. end
  21.  
  22. on mouseUp me
  23.   GoBack(me)
  24. end
  25.  
  26. on Initialize me
  27.   if voidp(gNavigationButtonList) then
  28.     gNavigationButtonList = [#stack: [], #forward: [], #index: []]
  29.   else
  30.     if gNavigationButtonList.ilk <> #propList then
  31.       ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  32.     else
  33.       if not gNavigationButtonList.findPos(#stack) then
  34.         ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  35.       else
  36.         if not gNavigationButtonList.findPos(#index) then
  37.           ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  38.         else
  39.           if not gNavigationButtonList.findPos(#forward) then
  40.             ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  41.           end if
  42.         end if
  43.       end if
  44.     end if
  45.   end if
  46.   theSprite = sprite(me.spriteNum)
  47.   theBehaviors = theSprite.scriptInstanceList
  48.   myState = -1
  49.   myStateBehavior = []
  50.   call(#PushButton_GetReference, theBehaviors, myStateBehavior)
  51. end
  52.  
  53. on CheckIfActive me
  54.   stackCount = count(gNavigationButtonList.stack)
  55.   stackState = stackCount <> 0
  56.   if myState = stackState then
  57.     exit
  58.   end if
  59.   myState = stackState
  60.   call(#PushButton_ToggleActive, myStateBehavior, stackState)
  61. end
  62.  
  63. on GoBack me
  64.   stackCount = count(gNavigationButtonList.stack)
  65.   if not stackCount then
  66.     exit
  67.   else
  68.     currentMarker = [#frame: marker(0), #movie: the movieName]
  69.     if not gNavigationButtonList.index.getPos(currentMarker) then
  70.       gNavigationButtonList.index.append(currentMarker)
  71.     end if
  72.     gNavigationButtonList.forward.append(currentMarker)
  73.     markerToGoTo = gNavigationButtonList.stack.getLast()
  74.     gNavigationButtonList.stack.deleteAt(stackCount)
  75.     theFrame = markerToGoTo.frame
  76.     theMovie = markerToGoTo.movie
  77.     if theMovie = the movieName then
  78.       go(theFrame)
  79.     else
  80.       go(theFrame, theMovie)
  81.     end if
  82.   end if
  83. end
  84.  
  85. on ErrorAlert me, theError, data
  86.   behaviorName = string(me)
  87.   delete word 1 of behaviorName
  88.   delete char -30001 of behaviorName
  89.   delete char -30001 of behaviorName
  90.   case data.ilk of
  91.     #void:
  92.       data = "<void>"
  93.     #symbol:
  94.       data = "#" & data
  95.   end case
  96.   case theError of
  97.     #invalidGlobal:
  98.       alert("BEHAVIOR ERROR: Frame " & the frame & ", Sprite " & me.spriteNum & RETURN & RETURN & "Behavior " & behaviorName & " requires a global gNavigationButtonList with the structure:" & RETURN & "[#stack [...], #index: [...], #forward: [...]]" & RETURN & RETURN & "Current value = " & data)
  99.       halt()
  100.   end case
  101. end
  102.